//
//  WFAddSavingsMethodButtonCell.m
//  WeiFang
//
//  Created by WeiFang on 2022.
//  Copyright ©2022年 WeiFang. All rights reserved.
//

#import "WFAddSavingsMethodButtonCell.h"

@implementation WFAddSavingsMethodButtonCell

+ (id)instanceView {
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    return [nibView objectAtIndex:0];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _myButton.adjustsImageWhenHighlighted = NO;
}

- (void)setData:(id)data delegate:(id)delegate {
    _delegate = delegate;
    
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[WFAddSavingsMethodButtonCellModel class]]) {
            WFAddSavingsMethodButtonCellModel *model = data[@"data"];
            [_myButton setTitle:model.title forState:UIControlStateNormal];
        }
    }
    
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(addSavingsMethodButtonCell:button:)]) {
        [_delegate addSavingsMethodButtonCell:self button:sender];
    }
}

@end


#pragma mark - Model

@implementation WFAddSavingsMethodButtonCellModel

+ (WFAddSavingsMethodButtonCellModel *)ittemModelWithTitle:(NSString *)title {
    WFAddSavingsMethodButtonCellModel *model = [WFAddSavingsMethodButtonCellModel new];
    model.title = kSafeString(title);
    return model;
}

@end
